{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->wurl('chapter', array('op' => 'post','did'=>$did))}">添加章节</a></li>
	<li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->wurl('chapter',array('did'=>$did))}">章节列表</a></li>
	<li><a href="{php echo $this->wurl('directory',array('bid'=>$directory['bid']))}">目录列表</a></li>
</ul>
{if $op == 'display'}
<style>
th{
	text-align: center !important;
}
td{
	text-align: center !important;
	white-space: normal !important;
	word-break: break-all !important;
	vertical-align: middle !important;
}
</style>
<form action="" method="get" class="form-horizontal" role="form">
	<div class="panel panel-info">
        <div class="panel-heading">筛选</div>
			<div class="panel-body">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{php echo $this->modulename}" />
                <input type="hidden" name="do" value="chapter" />
                <input type="hidden" name="did" value="{$did}" />
				<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">章节名称</label>
	                <div class="col-xs-12 col-sm-2 col-lg-2">
	                    <input class="form-control" name="title" type="text" value="{$title}" placeholder="">
	                </div>
                	<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
                    <div class=" col-xs-12 col-sm-3 col-lg-3">
                        <button class="btn btn-sm btn-default" ><i class="fa fa-search"></i> 搜索</button>
                   	</div>
				</div>
			</div>
        </div>
</form>			
<div class="main">
	<div class="cate" style="background: white;">
		<table class="table table-hover">
			<thead>
				<tr>
					<th>ID</th>
					<th>排序</th>
					<th>名称</th>
					<th>录音</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $list $item}
				<tr>
					<td>{$item['id']}</td>
					<td>{$item['sort']}</td>
					<td>{$item['title']}</td>
					<td>
					{if $item['link']}
						{if $item['type']==1}
						<video src="{php echo toimage($item['link'])}" controls="controls" height="150px"></video>
						{else}
						<audio controls="controls" src="{php echo toimage($item['link'])}"></audio>
						{/if}
					{/if}
					</td>
					<td>
						<a class="btn btn-sm btn-default" href="{php echo $this->wurl('chapter', array('op' => 'post', 'id' => $item['id'], 'did' => $did))}"><i class='fa fa-edit'></i>编辑</a>
						<a onclick="return confirm('确定删除吗？');return false;" href="{php echo $this->wurl('chapter',array('op'=>'del','id'=>$item['id'], 'did' => $did))}" class="btn btn-sm btn-danger"><i class="fa fa-remove"></i> 删除</a>
					</td>
				</tr>
			{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{/if}
{if $op == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form">
		<input type="hidden" name="id" value="{$id}" />
		<input type="hidden" name="did" value="{$did}" />
        <div class="panel panel-default">
            <div class="panel-heading">
                详情设置
            </div>
            <div class="panel-body">
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">名称</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="title" class="form-control" value="{$item['title']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">章节类型</label>
                    <div class="col-sm-9 col-xs-12">
                        <label onclick="showTypw(0)" class="radio-inline"><input type="radio" name="type" value="0" {if $item['type']==0}checked{/if}>音频</label>
                        <label onclick="showTypw(1)" class="radio-inline"><input type="radio" name="type" value="1" {if $item['type']==1}checked{/if}>视频</label>
                    </div>
                </div>
				<div class="form-group linnktype linktype0" {if $item['type']==1}style="display:none;"{/if}>
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">录音</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_audio('link',$item['link'])}
                    </div>
                </div>
				<div class="form-group linnktype linktype1" {if $item['type']==0}style="display:none;"{/if}>
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">视频</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_video('link1',$item['link'])}
                    </div>
                </div>
<script>                
function showTypw(type){
	$('.linnktype').hide();
	$('.linktype'+type).show();
}
</script>                
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="number" name="sort" class="form-control" value="{$item['sort']}" />
                    </div>
                </div>
				<!-- <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">时长</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class='input-group'>
                        	<input type="number" name="times" class="form-control" value="{$item['times']}" />
							<div class='input-group-addon'>秒</div>  
                        </div>
                    </div>
                </div> -->
                <div class="form-group" >
		            <label class="col-xs-12 col-sm-3 col-md-2 control-label">文稿</label>
		            <div class="col-sm-9 col-xs-12">
		                {php echo tpl_ueditor('detail',$item['detail'], array('height'=>360));}
		            </div>
		        </div>
			</div>
		</div>
        <input name="submit" type="submit" value="提交" class="btn btn-sm btn-primary span3">
        <input type="hidden" name="token" value="{$_W['token']}" />
	</form>
</div>
{/if}
{template 'common/footer'}